#define _CRT_SECURE_NO_WARNINGS
#include <iostream>

using namespace std;
typedef long long LL;

int k, x, n;
const int N = 1010, M = 110, K = 150;
int f[M][K];
LL qpow(LL a, LL b, LL p)
{
	a %= p;
	LL ret = 1;
	while (b)
	{
		if (b & 1) ret = ret * a % p;
		b >>= 1;
		a = a * a % p;
	}
	return ret;
}
void add(int c[], int a[], int b[])
{
	for (int i = 0; i < K - 1; i++)
	{
		c[i] += b[i];
		c[i + 1] += c[i] / 10;
		c[i] %= 10;
	}
}
int main()
{
	cin >> k >> x;

	n = qpow(x, x, 1000);
	for (int i = 0; i < n; i++)
	{
		f[0][0] = 1;
		for (int j = min(i, k); j >= 1; j--)
		{
			add(f[j], f[j], f[j - 1]);
		}
	}
	
	int p = K - 1;
	while (f[k - 1][p] == 0) p--;
	while (p >= 0) cout << f[k - 1][p--];
	return 0;
}